﻿////////////////////////////////////////////
//简单的查看地图数据的控件
//因为简单，想要扩展功能就最好编写子类继承（虽然当前的设计在继承上并不方便）
///////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SystemUI;
using ESRI.ArcGIS.Controls;
using DevExpress.XtraBars;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using System.IO;
using CommonLib;

namespace FormLib.UserControls
{
    public partial class MapViewer : DevExpress.XtraEditors.XtraUserControl, IViewer
    {
        private bool m_preLeftShow = true;
        public DevExpress.XtraEditors.LabelControl lblTips = null;
        public DevExpress.XtraEditors.LabelControl lblCurCoors = null;
        public DevExpress.XtraEditors.LabelControl lblScaleInfo = null;
        private DevExpress.XtraEditors.XtraForm qrf = new DevExpress.XtraEditors.XtraForm();
        private Dictionary<string, string> chsDic = new Dictionary<string, string>();
        private IFeatureLayer m_queryFeatureLayer=null;
        private IFeature m_queryFeature=null;
        public MapViewer()
        {
            InitializeComponent();
            lblTips = new DevExpress.XtraEditors.LabelControl();
            lblCurCoors = new DevExpress.XtraEditors.LabelControl();
            lblScaleInfo = new DevExpress.XtraEditors.LabelControl();
        }

        private void MapViewer_Load(object sender, EventArgs e)
        {
            //地图导航默认平移
            ESRI.ArcGIS.SystemUI.ICommand command = null;
            command = new ESRI.ArcGIS.Controls.ControlsMapPanTool();
            if (command != null)
            {
                command.OnCreate(axMapControlMainMap.Object);
                if (command is ITool)
                    axMapControlMainMap.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool;
                else
                    command.OnClick();
            }
        }

        ~MapViewer()
        {
            axMapControlMainMap.Dispose();
        }

        public void LoadFile(string filename)
        {
            if (File.Exists(filename))
            {
                axMapControlMainMap.LoadMxFile(filename);
                this.axMapControlMainMap.Map.Name = filename.Substring(filename.LastIndexOf("\\") + 1, filename.Length - 5 - filename.LastIndexOf("\\"));
            }
            else
            {
                MessageBox.Show("地图加载失败，请检查地图数据路径是否正确！", "错误");
            }
        }

        public void Close()
        {
            axMapControlMainMap.Dispose();
        }

        public void sBtnExpend_Click(object sender, EventArgs e)
        {
            if (m_preLeftShow)
            {
                m_preLeftShow = false;
                panelControl1.Dock = DockStyle.None;
                panelControl1.Size = this.sBtnExpend.Size + new Size(2, 2); ;
                panelControl1.Location = this.axMapControlMainMap.Location;
                //new Size(4, 4);
                splitterControl1.Visible = false;
                sBtnExpend.Text = ">";
            }
            else
            {
                m_preLeftShow = true;
                //panelControl1.Size = new System.Drawing.Size(simpleButton1.Width + 4, axMapControl1.Height);
                panelControl1.Dock = DockStyle.Left;
                panelControl1.Size = new Size(196, 484);
                splitterControl1.Visible = true;
                sBtnExpend.Text = "<";
            }
        }
        private IPoint m_identityPoint = null;
        private void axMapControlMainMap_OnMouseDown(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseDownEvent e)
        {
            int statusFlag = CommonLib.CommonTools.MapMouseFlag;
            string layerField = CommonLib.AETools.tagetLayerField;
            string layerName = CommonLib.AETools.tagetLayerName;//目标图层名

            if (statusFlag <= 1) return;
            axMapControlMainMap.MousePointer = esriControlsMousePointer.esriPointerCrosshair;//鼠标指针:十字状
            IPoint pPoint = axMapControlMainMap.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            m_identityPoint = axMapControlMainMap.ToMapPoint(e.x, e.y);
            IFeatureLayer featureLayer = null;
            IFeatureLayer YDFeatureLayer = null;
            switch (statusFlag)
            {
                #region 地价查询
                case 10001:
                    this.dockPnlQueryForm.Text = "查询窗口-市区商业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap,layerName);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10002:
                    this.dockPnlQueryForm.Text = "查询窗口-市区住宅基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10003:
                    this.dockPnlQueryForm.Text = "查询窗口-市区工业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10004:
                    this.dockPnlQueryForm.Text = "查询窗口-市区商业路线基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10005:
                    this.dockPnlQueryForm.Text = "查询窗口-市区标定地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10006:
                    this.dockPnlQueryForm.Text = "查询窗口-合水镇商业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10007:
                    this.dockPnlQueryForm.Text = "查询窗口-合水镇住宅基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10008:
                    this.dockPnlQueryForm.Text = "查询窗口-合水镇工业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10009:
                    this.dockPnlQueryForm.Text = "查询窗口-怀乡镇商业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10010:
                    this.dockPnlQueryForm.Text = "查询窗口-怀乡镇住宅基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10011:
                    this.dockPnlQueryForm.Text = "查询窗口-怀乡镇工业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10012:
                    this.dockPnlQueryForm.Text = "查询窗口-镇隆镇商业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10013:
                    this.dockPnlQueryForm.Text = "查询窗口-镇隆镇住宅基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10014:
                    this.dockPnlQueryForm.Text = "查询窗口-镇隆镇工业基准地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                case 10015:
                    this.dockPnlQueryForm.Text = "查询窗口-其他地价综合地价";
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    this.getIdentifyResults(featureLayer);
                    break;
                #endregion

                #region 地价测算（按基准）
                case 20001: 
                    //featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    this.calSelectedFeatureByJZ(featureLayer,"市区商业宗地价格测算");
                    break;
                case 20002:
                    //featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    this.calSelectedFeatureByJZ(featureLayer, "市区住宅宗地价格测算");
                    break;
                case 20003: 
                    //featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    this.calSelectedFeatureByJZ(featureLayer, "市区工业宗地价格测算");
                    break;
                #endregion

                #region 地价测算（按标定）
                case 30001: 
                    //featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap,layerName);
                    YDFeatureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, CommonLib.AETools.YDLayerName);
                    this.byBDPriceCaculation(featureLayer, YDFeatureLayer, "市区商业基准地价");
                    //this.calSelectedFeatureByBD(featureLayer, null);//缺省中
                    break;
                case 30002: 
                    //featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    YDFeatureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, CommonLib.AETools.YDLayerName);
                    this.ZZbyBDPriceCaculation(featureLayer, YDFeatureLayer, "市区住宅基准地价");
                    break;
                case 30003: 
                    //featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerField, 0);
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    YDFeatureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, CommonLib.AETools.YDLayerName);
                    this.GYbyBDPriceCaculation(featureLayer, YDFeatureLayer, "市区工业基准地价");
                    break;
                #endregion

                #region 出让价格测算（按照标定地价测算宗地价格后，乘以40%即为宗地出让价格）
                case 30004: 
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap,layerName);
                    YDFeatureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, CommonLib.AETools.YDLayerName);
                    //this.byBDPriceCaculation(featureLayer, YDFeatureLayer);

                    calSellPriceOfSelectedFeature(featureLayer, "商业宗地");
                    //this.calSelectedFeatureByBD(featureLayer, null);//缺省中
                    break;
                case 30005: 
                    featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    YDFeatureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, CommonLib.AETools.YDLayerName);
                    //this.ZZbyBDPriceCaculation(featureLayer, YDFeatureLayer);
                    calSellPriceOfSelectedFeature(featureLayer, "住宅宗地");

                    break;
                case 30006:
                     featureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, layerName);
                    YDFeatureLayer = CommonLib.AETools.GetFeatureLayer(this.axMapControlMainMap, CommonLib.AETools.YDLayerName);
                    //this.GYbyBDPriceCaculation(featureLayer, YDFeatureLayer);
                    //this.calSelectedFeatureByBD(featureLayer, null);//缺省中
                    calSellPriceOfSelectedFeature(featureLayer, "工业宗地");
                    break;
                #endregion
            }
        }

        #region 商业标定地价计算主要方法
        /// <summary>
        /// 标定地价计算器
        /// </summary>
        /// <param name="selectedFeatureLayer">宗地要素图层</param>
        /// <param name="targetFeatureLayer">样本点要素图层</param>
        private void byBDPriceCaculation(IFeatureLayer selectedFeatureLayer, IFeatureLayer YDFeatureLayer,string operationName)
        {
            IPoint point1;
            if (selectedFeatureLayer == null) return;
            IGeometry identityPoint = m_identityPoint;//identify点（缓冲1）
            point1 = m_identityPoint;
            #region identify点缓冲
            ITopologicalOperator topoOp = m_identityPoint as ITopologicalOperator;
            identityPoint = topoOp.Buffer(1);
            #endregion

            IIdentify2 identify2 = selectedFeatureLayer as IIdentify2;
            IArray identifyResultObjs = identify2.Identify(identityPoint, null);

            //如果没有选择宗地图层中的要素则不作任何操作
            if (identifyResultObjs == null && identifyResultObjs.Count == 0)//循环该图层identify的每一个结果
                return;

            IFeatureIdentifyObj IdentifyObj = identifyResultObjs.get_Element(0) as IFeatureIdentifyObj;
            IRowIdentifyObject rowIdentifyObj = IdentifyObj as IRowIdentifyObject;
            //确定测算宗地对象
            IFeature identifyFeature = rowIdentifyObj.Row as IFeature;

            #region 遍历样点图层中的要素获取集合(得到要素；计算距离；生成List；List排序；得到List中前三个点;通过三个点数据计算标定地价)
            List<UtilityClass> list = new List<UtilityClass>();
            IFeatureClass pFeatureClass = YDFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, true);
            IFeature pFeature;
            int key1 = pFeatureClass.Fields.FindField(CommonLib.AETools.YDLayerField);
            int key2 = pFeatureClass.Fields.FindField(CommonLib.AETools.RJLXZXS);
            int key3 = pFeatureClass.Fields.FindField(CommonLib.AETools.SYNQXZXS);
            int key4 = pFeatureClass.Fields.FindField(CommonLib.AETools.LJSDXZXS);
            int key5 = pFeatureClass.Fields.FindField(CommonLib.AETools.KSBXZXS);
            int key6 = pFeatureClass.Fields.FindField(CommonLib.AETools.ZDXZXZXS);
            int key7 = pFeatureClass.Fields.FindField(CommonLib.AETools.JJDXZXS);
            int key8 = pFeatureClass.Fields.FindField(CommonLib.AETools.KFCDXZXS);
            int key9 = pFeatureClass.Fields.FindField(CommonLib.AETools.EJFLXZXS);

            while ((pFeature = pFeatureCursor.NextFeature()) != null)
            {
                UtilityClass utilityClass = new UtilityClass();
                IPoint point2 = pFeature.Shape as IPoint;
                double distance = getDistanceBetweenPoint(point1, point2);

                utilityClass.Distance = distance;
                utilityClass.BDDJ1 = Convert.ToInt16(pFeature.get_Value(key1));
                utilityClass.RJLXZXS1 = Convert.ToDouble(pFeature.get_Value(key2));
                utilityClass.SYNQXZXS1 = Convert.ToDouble(pFeature.get_Value(key3));

                utilityClass.LJSDXZXS1 = Convert.ToDouble(pFeature.get_Value(key4));
                utilityClass.KSBXZXS1 = Convert.ToDouble(pFeature.get_Value(key5));

                utilityClass.ZDXZXZXS1 = Convert.ToDouble(pFeature.get_Value(key6));
                utilityClass.JJDXZXS1 = Convert.ToDouble(pFeature.get_Value(key7));

                utilityClass.KFCDXZXS1 = Convert.ToDouble(pFeature.get_Value(key8));
                utilityClass.EJFLXZXS1 = Convert.ToDouble(pFeature.get_Value(key9));

                list.Add(utilityClass);
            }
            //list排序
            list.Sort();

            //计算宗地标定地价
            //判断是计算标定地价，还是计算出让价格
            int currentBDDJ = 0;
            if (CommonLib.CommonTools.MapMouseFlag == 30004)
            {
                currentBDDJ = Convert.ToInt16(caculateBDDJ(list, 3)*0.4);
            }
            else if (CommonLib.CommonTools.MapMouseFlag == 30001)
            {
                currentBDDJ = caculateBDDJ(list, 3);
            }

            #endregion

            #region (将currentBDDJ写入到目标宗地图层的BDDJ字段中区，并显示DJCalForm接口进行标定地价计算)
            /*
            try
            {
                
                pFeatureClass = selectedFeatureLayer.FeatureClass;
                IQueryFilter pQ = new QueryFilterClass();
                pQ.WhereClause = "OBJECTID = " + identifyFeature.OID;
                

                IWorkspace pWork = (pFeatureClass as IDataset).Workspace;
                IWorkspaceEdit pwedit = pWork as IWorkspaceEdit;
                pwedit.StartEditOperation();
                pwedit.StartEditing(false);
                pFeatureCursor = pFeatureClass.Update(pQ, true);
                pFeature = pFeatureCursor.NextFeature();
                int s  = identifyFeature.Fields.FindField(CommonLib.AETools.tagetLayerField);
                pFeature.set_Value(s, currentBDDJ);
                pFeatureCursor.UpdateFeature(pFeature);

                pwedit.StopEditOperation();
                pwedit.StopEditing(true);
            }
            catch (Exception ee)
            {
                MessageBox.Show(ee.Message);
            }
            */

            string calContent = operationName;
            string jzjb = identifyFeature.get_Value(identifyFeature.Fields.FindField("级别")).ToString();
           FormStyle.OpenForm(this.ParentForm,new DJCalForm(selectedFeatureLayer, identifyFeature, calContent, currentBDDJ.ToString(), jzjb),true);
            #endregion

        }
       
        //样点处理类，存放样点数据
        private class UtilityClass : IComparable
        {
            private double distance;

            public double Distance
            {
                get { return distance; }
                set { distance = value; }
            }
            private Int16 BDDJ;

            public Int16 BDDJ1
            {
                get { return BDDJ; }
                set { BDDJ = value; }
            }
            private double RJLXZXS;

            public double RJLXZXS1
            {
                get { return RJLXZXS; }
                set { RJLXZXS = value; }
            }
            private double SYNQXZXS;

            public double SYNQXZXS1
            {
                get { return SYNQXZXS; }
                set { SYNQXZXS = value; }
            }
            private double LJSDXZXS;

            public double LJSDXZXS1
            {
                get { return LJSDXZXS; }
                set { LJSDXZXS = value; }
            }
            private double KSBXZXS;

            public double KSBXZXS1
            {
                get { return KSBXZXS; }
                set { KSBXZXS = value; }
            }
            private double ZDXZXZXS;

            public double ZDXZXZXS1
            {
                get { return ZDXZXZXS; }
                set { ZDXZXZXS = value; }
            }
            private double JJDXZXS;

            public double JJDXZXS1
            {
                get { return JJDXZXS; }
                set { JJDXZXS = value; }
            }
            private double KFCDXZXS;

            public double KFCDXZXS1
            {
                get { return KFCDXZXS; }
                set { KFCDXZXS = value; }
            }
            private double EJFLXZXS;

            public double EJFLXZXS1
            {
                get { return EJFLXZXS; }
                set { EJFLXZXS = value; }
            }



            public int CompareTo(object obj)
            {
                if (obj is UtilityClass)
                {
                    UtilityClass u = obj as UtilityClass;
                    return this.Distance.CompareTo(u.Distance);
                }
                throw new NotImplementedException();
            }

        }
        //得到两点间的距离
        private double getDistanceBetweenPoint(IPoint point1,IPoint point2)
        {
            IProximityOperator pProximi;
            pProximi = point1 as IProximityOperator;
            double distance = pProximi.ReturnDistance(point2);
            return distance;
        }
        //宗地标定地价计算公式,count表示周围点的数目
        private int caculateBDDJ(List<UtilityClass> list,int count)
        {
            int bddj = 0;
            double overBDDJ = 0;
            for (int i = 0; i < count; i++)
            {
                UtilityClass u = list[i];
                double temp = u.BDDJ1 / u.EJFLXZXS1 / u.JJDXZXS1 / u.KFCDXZXS1 / u.KSBXZXS1 / u.LJSDXZXS1 / u.RJLXZXS1 / u.SYNQXZXS1 / u.ZDXZXZXS1;
                overBDDJ = overBDDJ + temp;
            }

            bddj = Convert.ToInt16(overBDDJ);
            return bddj;
        }
        #endregion

        #region 住宅标定地价计算主要方法
        /// <summary>
        /// 标定地价计算器
        /// </summary>
        /// <param name="selectedFeatureLayer">宗地要素图层</param>
        /// <param name="targetFeatureLayer">样本点要素图层</param>
        private void ZZbyBDPriceCaculation(IFeatureLayer selectedFeatureLayer, IFeatureLayer YDFeatureLayer,string operationName)
        {
            IPoint point1;
            if (selectedFeatureLayer == null) return;
            IGeometry identityPoint = m_identityPoint;//identify点（缓冲1）
            point1 = m_identityPoint;
            #region identify点缓冲
            ITopologicalOperator topoOp = m_identityPoint as ITopologicalOperator;
            identityPoint = topoOp.Buffer(1);
            #endregion

            IIdentify2 identify2 = selectedFeatureLayer as IIdentify2;
            IArray identifyResultObjs = identify2.Identify(identityPoint, null);

            //如果没有选择宗地图层中的要素则不作任何操作
            if (identifyResultObjs == null && identifyResultObjs.Count == 0)//循环该图层identify的每一个结果
                return;

            IFeatureIdentifyObj IdentifyObj = identifyResultObjs.get_Element(0) as IFeatureIdentifyObj;
            IRowIdentifyObject rowIdentifyObj = IdentifyObj as IRowIdentifyObject;
            //确定测算宗地对象
            IFeature identifyFeature = rowIdentifyObj.Row as IFeature;

            #region 遍历样点图层中的要素获取集合(得到要素；计算距离；生成List；List排序；得到List中前三个点;通过三个点数据计算标定地价)
            List<ZZUtilityClass> list = new List<ZZUtilityClass>();
            IFeatureClass pFeatureClass = YDFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, true);
            IFeature pFeature;

            int key1 = pFeatureClass.Fields.FindField(CommonLib.AETools.YDLayerField);
            int key2 = pFeatureClass.Fields.FindField(CommonLib.AETools.RJLXZXS);
            int key3 = pFeatureClass.Fields.FindField(CommonLib.AETools.SYNQXZXS);
            int key4 = pFeatureClass.Fields.FindField(CommonLib.AETools.LJSDXZXS);
            int key5 = pFeatureClass.Fields.FindField(CommonLib.AETools.KSBXZXS);
            int key6 = pFeatureClass.Fields.FindField(CommonLib.AETools.ZDXZXZXS);
            int key7 = pFeatureClass.Fields.FindField(CommonLib.AETools.JJDXZXS);
 

            while ((pFeature = pFeatureCursor.NextFeature()) != null)
            {
                ZZUtilityClass utilityClass = new ZZUtilityClass();
                IPoint point2 = pFeature.Shape as IPoint;
                double distance = getDistanceBetweenPoint(point1, point2);

                utilityClass.Distance = distance;
                utilityClass.BDDJ1 = Convert.ToInt16(pFeature.get_Value(key1));
                utilityClass.RJLXZXS1 = Convert.ToDouble(pFeature.get_Value(key2));
                utilityClass.SYNQXZXS1 = Convert.ToDouble(pFeature.get_Value(key3));

                utilityClass.ZDXZXZXS1 = Convert.ToDouble(pFeature.get_Value(key4));
                utilityClass.JGHJXZXS1 = Convert.ToDouble(pFeature.get_Value(key5));

                utilityClass.LLTJXZXS1 = Convert.ToDouble(pFeature.get_Value(key6));
                utilityClass.KFCDXZXS1 = Convert.ToDouble(pFeature.get_Value(key7));

                

                list.Add(utilityClass);
            }
            //list排序
            list.Sort();


            //判断是计算标定地价，还是计算出让价格
            int currentBDDJ = 0;
            if (CommonLib.CommonTools.MapMouseFlag == 30005)
            {
                currentBDDJ = Convert.ToInt16(ZZcaculateBDDJ(list, 3) * 0.4);
            }
            else if (CommonLib.CommonTools.MapMouseFlag == 30002)
            {
                currentBDDJ = ZZcaculateBDDJ(list, 3);
            }
           

            #endregion

            #region (将currentBDDJ写入到目标宗地图层的BDDJ字段中区，并显示DJCalForm接口进行标定地价计算)


            string calContent = operationName;
            string jzjb = identifyFeature.get_Value(identifyFeature.Fields.FindField("级别")).ToString();
            //DJCalForm djCalForm = new DJCalForm(selectedFeatureLayer, identifyFeature, calContent, currentBDDJ.ToString(), jzjb);
            //djCalForm.Show();
            FormStyle.OpenForm(this.ParentForm, new DJCalForm(selectedFeatureLayer, identifyFeature, calContent, currentBDDJ.ToString(), jzjb), true);
            #endregion

        }

        //样点处理类，存放样点数据
        private class ZZUtilityClass : IComparable
        {
            private double distance;

            public double Distance
            {
                get { return distance; }
                set { distance = value; }
            }
            private Int16 BDDJ;

            public Int16 BDDJ1
            {
                get { return BDDJ; }
                set { BDDJ = value; }
            }
            private double RJLXZXS;

            public double RJLXZXS1
            {
                get { return RJLXZXS; }
                set { RJLXZXS = value; }
            }
            private double SYNQXZXS;

            public double SYNQXZXS1
            {
                get { return SYNQXZXS; }
                set { SYNQXZXS = value; }
            }

            private double ZDXZXZXS;

            public double ZDXZXZXS1
            {
                get { return ZDXZXZXS; }
                set { ZDXZXZXS = value; }
            }
            private double JGHJXZXS;

            public double JGHJXZXS1
            {
                get { return JGHJXZXS; }
                set { JGHJXZXS = value; }
            }
            private double LLTJXZXS;

            public double LLTJXZXS1
            {
                get { return LLTJXZXS; }
                set { LLTJXZXS = value; }
            }
            private double KFCDXZXS;

            public double KFCDXZXS1
            {
                get { return KFCDXZXS; }
                set { KFCDXZXS = value; }
            }


            public int CompareTo(object obj)
            {
                if (obj is ZZUtilityClass)
                {
                    ZZUtilityClass u = obj as ZZUtilityClass;
                    return this.Distance.CompareTo(u.Distance);
                }
                throw new NotImplementedException();
            }

        }
       
        //宗地标定地价计算公式,count表示周围点的数目
        private int ZZcaculateBDDJ(List<ZZUtilityClass> list, int count)
        {
            int bddj = 0;
            double overBDDJ = 0;
            for (int i = 0; i < count; i++)
            {
                ZZUtilityClass u = list[i];
                double temp = u.BDDJ1 / u.JGHJXZXS1 / u.KFCDXZXS1 / u.LLTJXZXS1 / u.RJLXZXS1 / u.SYNQXZXS1 / u.ZDXZXZXS1;
                overBDDJ = overBDDJ + temp;
            }

            bddj = Convert.ToInt16(overBDDJ);
            return bddj;
        }
        #endregion

        #region 工业标定地价计算主要方法
        /// <summary>
        /// 标定地价计算器
        /// </summary>
        /// <param name="selectedFeatureLayer">宗地要素图层</param>
        /// <param name="targetFeatureLayer">样本点要素图层</param>
        private void GYbyBDPriceCaculation(IFeatureLayer selectedFeatureLayer, IFeatureLayer YDFeatureLayer,string operationName)
        {
            IPoint point1;
            if (selectedFeatureLayer == null) return;
            IGeometry identityPoint = m_identityPoint;//identify点（缓冲1）
            point1 = m_identityPoint;
            #region identify点缓冲
            ITopologicalOperator topoOp = m_identityPoint as ITopologicalOperator;
            identityPoint = topoOp.Buffer(1);
            #endregion

            IIdentify2 identify2 = selectedFeatureLayer as IIdentify2;
            IArray identifyResultObjs = identify2.Identify(identityPoint, null);

            //如果没有选择宗地图层中的要素则不作任何操作
            if (identifyResultObjs == null && identifyResultObjs.Count == 0)//循环该图层identify的每一个结果
                return;

            IFeatureIdentifyObj IdentifyObj = identifyResultObjs.get_Element(0) as IFeatureIdentifyObj;
            IRowIdentifyObject rowIdentifyObj = IdentifyObj as IRowIdentifyObject;
            //确定测算宗地对象
            IFeature identifyFeature = rowIdentifyObj.Row as IFeature;

            #region 遍历样点图层中的要素获取集合(得到要素；计算距离；生成List；List排序；得到List中前三个点;通过三个点数据计算标定地价)
            List<GYUtilityClass> list = new List<GYUtilityClass>();
            IFeatureClass pFeatureClass = YDFeatureLayer.FeatureClass;
            IFeatureCursor pFeatureCursor = pFeatureClass.Search(null, true);
            IFeature pFeature;
            int key1 = pFeatureClass.Fields.FindField(CommonLib.AETools.YDLayerField);
            int key2 = pFeatureClass.Fields.FindField(CommonLib.AETools.RJLXZXS);
            int key3 = pFeatureClass.Fields.FindField(CommonLib.AETools.SYNQXZXS);
            int key4 = pFeatureClass.Fields.FindField(CommonLib.AETools.LJSDXZXS);
       
            while ((pFeature = pFeatureCursor.NextFeature()) != null)
            {
                GYUtilityClass utilityClass = new GYUtilityClass();
                IPoint point2 = pFeature.Shape as IPoint;
                double distance = getDistanceBetweenPoint(point1, point2);

                utilityClass.Distance = distance;
                utilityClass.BDDJ1 = Convert.ToInt16(pFeature.get_Value(key1));
                utilityClass.SYNQXZXS1 = Convert.ToDouble(pFeature.get_Value(key2));
                utilityClass.ZDXZXZXS1 = Convert.ToDouble(pFeature.get_Value(key3));

                utilityClass.KFCDXZXS1 = Convert.ToDouble(pFeature.get_Value(key4));
               



                list.Add(utilityClass);
            }
            //list排序
            list.Sort();

            //判断是计算标定地价，还是计算出让价格
            int currentBDDJ = 0;
            if (CommonLib.CommonTools.MapMouseFlag == 30006)
            {
                currentBDDJ = Convert.ToInt16(GYcaculateBDDJ(list, 3) * 0.4);
            }
            else if (CommonLib.CommonTools.MapMouseFlag == 30003)
            {
                currentBDDJ = GYcaculateBDDJ(list, 3);
            }
            

            #endregion

            #region (将currentBDDJ写入到目标宗地图层的BDDJ字段中区，并显示DJCalForm接口进行标定地价计算)


            string calContent = operationName;
            string jzjb = identifyFeature.get_Value(identifyFeature.Fields.FindField("级别")).ToString();
            FormStyle.OpenForm(this.ParentForm,new DJCalForm(selectedFeatureLayer, identifyFeature, calContent, currentBDDJ.ToString(), jzjb),true );
            //djCalForm.Show();
            #endregion

        }
        //样点处理类，存放样点数据
        private class GYUtilityClass : IComparable
        {
            private double distance;

            public double Distance
            {
                get { return distance; }
                set { distance = value; }
            }
            private Int16 BDDJ;

            public Int16 BDDJ1
            {
                get { return BDDJ; }
                set { BDDJ = value; }
            }

            private double SYNQXZXS;

            public double SYNQXZXS1
            {
                get { return SYNQXZXS; }
                set { SYNQXZXS = value; }
            }
            private double ZDXZXZXS;

            public double ZDXZXZXS1
            {
                get { return ZDXZXZXS; }
                set { ZDXZXZXS = value; }
            }
            private double KFCDXZXS;

            public double KFCDXZXS1
            {
                get { return KFCDXZXS; }
                set { KFCDXZXS = value; }
            }


            public int CompareTo(object obj)
            {
                if (obj is GYUtilityClass)
                {
                    GYUtilityClass u = obj as GYUtilityClass;
                    return this.Distance.CompareTo(u.Distance);
                }
                throw new NotImplementedException();
            }

        }

        //宗地标定地价计算公式,count表示周围点的数目
        private int GYcaculateBDDJ(List<GYUtilityClass> list, int count)
        {
            int bddj = 0;
            double overBDDJ = 0;
            for (int i = 0; i < count; i++)
            {
                GYUtilityClass u = list[i];
                double temp = u.BDDJ1 / u.KFCDXZXS1 / u.SYNQXZXS1 / u.ZDXZXZXS1;
                overBDDJ = overBDDJ + temp;
            }

            bddj = Convert.ToInt16(overBDDJ);
            return bddj;
        }
        #endregion

        private void axMapControlMainMap_OnMouseMove(object sender, ESRI.ArcGIS.Controls.IMapControlEvents2_OnMouseMoveEvent e)
        {
            #region 主地图上移动鼠标时，状态栏显示当前坐标、比例尺等信息
            //将当前鼠标位置的点转换为地图上的坐标
            IPoint point = axMapControlMainMap.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(e.x, e.y);
            //显示当前比例尺
            lblScaleInfo.Text = " 比例尺：  1/" + ((long)this.axMapControlMainMap.MapScale).ToString() + "   ";
            //显示当前坐标
            lblCurCoors.Text = " 当前坐标:  X=" + e.mapX.ToString() + "，  Y=" + e.mapY.ToString() + "   ";
            #endregion
        }

        #region 地图导航条（Navigation）
        private void barBtnSelectElement_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            #region 方法一：利用arcgis的command
            CommonLib.CommonTools.MapMouseFlag = 1;
            DevExpress.XtraBars.BarButtonItem barBtn = e.Item as DevExpress.XtraBars.BarButtonItem;
            ESRI.ArcGIS.SystemUI.ICommand command = null;
            switch (barBtn.Name)
            {
                case "barBtnSelectElement":  //指针（SelectElment）
                    CommonLib.CommonTools.MapMouseFlag = -1;
                    this.axMapControlMainMap.CurrentTool = null;
                    this.axMapControlMainMap.MousePointer = 0;//鼠标指针:十字状
                    break;
                case "barBtnFullExtent":  //全屏
                    command = new ESRI.ArcGIS.Controls.ControlsMapFullExtentCommand();
                    lblTips.Text = " 全屏";
                    break;
                case "barBtnZoomIn":      //放大
                    command = new ESRI.ArcGIS.Controls.ControlsMapZoomInTool();
                    lblTips.Text = " 放大";
                    break;
                case "barBtnZoomOut":     //缩小
                    command = new ESRI.ArcGIS.Controls.ControlsMapZoomOutTool();
                    lblTips.Text = " 缩小";
                    break;
                case "barBtnPan":         //平移
                    command = new ESRI.ArcGIS.Controls.ControlsMapPanTool();
                    lblTips.Text = " 平移";
                    break;
                case "barBtnPreView":     //上一视图
                    command = new ESRI.ArcGIS.Controls.ControlsMapZoomToLastExtentBackCommand();
                    lblTips.Text = " 上一视图";
                    break;
                case "barBtnNextView":    //下一视图
                    command = new ESRI.ArcGIS.Controls.ControlsMapZoomToLastExtentForwardCommand();
                    lblTips.Text = " 下一视图";
                    break;
                case "barBtnIdentify":    //属性查看
                    command = new ESRI.ArcGIS.Controls.ControlsMapIdentifyTool();
                    lblTips.Text = " 属性查看";
                    break;
                case "barBtnSelectFeature":    //选择
                    command = new ESRI.ArcGIS.Controls.ControlsGlobeSelectFeaturesTool();
                    lblTips.Text = " 选择";
                    break;
                case "barBtnClearSelection":    //清空
                    command = new ESRI.ArcGIS.Controls.ControlsClearSelectionCommand();
                    lblTips.Text = " 清空";
                    break;
                default:
                    break;
            }
            if (command != null)
            {
                command.OnCreate(axMapControlMainMap.Object);
                if (command is ITool)
                    axMapControlMainMap.CurrentTool = command as ESRI.ArcGIS.SystemUI.ITool;
                else
                    command.OnClick();
            }
            #endregion

            #region 方法二：先建立一个ArcGIS的ToolbarControl控件，将相应功能添加进去，然后模拟鼠标点击调用该功能
            //DevComponents.DotNetBar.BubbleButton button = sender as DevComponents.DotNetBar.BubbleButton;
            //ESRI.ArcGIS.SystemUI.ICommand command = null;
            //command = axToolbarControl1.CommandPool.get_Command(1);   //模拟ToolbarControl控件的第一按钮被点击
            //command.OnClick();
            #endregion
        }

        #endregion

        private void axMapControlMainMap_OnDoubleClick(object sender, IMapControlEvents2_OnDoubleClickEvent e)//双击省图的选中要素追溯其包括的县级图斑，或者双击县级数据库中的图斑，追溯其对应的省级图斑
        {
            if (axMapControlMainMap.LayerCount == 0) return;
        }

        /// <summary>获取查询的结果
        /// </summary>
        /// <param name="selectedFeatureLayer"></param>
        private void getIdentifyResults(IFeatureLayer selectedFeatureLayer)//获取查询的结果
        {
            try
            {
                if (selectedFeatureLayer == null) return;
                CommonLib.XMLConfig chsDicXMLConfig = new CommonLib.XMLConfig("Chs.xml");
                chsDic = chsDicXMLConfig.GetNamePairAlisaNameDic("Chs", "en", "chs");
                IGeometry identityPoint = m_identityPoint;//identify点（缓冲1）
                #region identify点缓冲
                ITopologicalOperator topoOp = m_identityPoint as ITopologicalOperator;
                identityPoint = topoOp.Buffer(1);
                #endregion
                #region identity
                IIdentify2 identify2 = selectedFeatureLayer as IIdentify2;
                IArray identifyResultObjs = identify2.Identify(identityPoint, null);
                if (identifyResultObjs != null && identifyResultObjs.Count > 0)//循环该图层identify的每一个结果
                {
                    IFeatureIdentifyObj IdentifyObj = identifyResultObjs.get_Element(0) as IFeatureIdentifyObj;
                    IRowIdentifyObject rowIdentifyObj = IdentifyObj as IRowIdentifyObject;
                    IFeature identifyFeature = rowIdentifyObj.Row as IFeature;
                    if (identifyFeature != null)
                    {
                        this.lsvQueryResult.Items.Clear();
                        SelectOnMouseDown(selectedFeatureLayer, identifyFeature);
                        List<ListViewItem> lsvItemList = new List<ListViewItem>();
                        for (int i = 0; i < identifyFeature.Fields.FieldCount; i++)
                        {
                            if (identifyFeature.Fields.Field[i].Name.ToLower().Contains("object") || identifyFeature.Fields.Field[i].Name.ToLower().Contains("shape") || identifyFeature.Fields.Field[i].Name.ToLower().Contains("join")) continue;
                            string itemName = identifyFeature.Fields.Field[i].Name;
                            if (chsDic.ContainsKey(identifyFeature.Fields.Field[i].Name))
                            {
                                itemName = chsDic[identifyFeature.Fields.Field[i].Name];
                            }
                            if (itemName == "") itemName = identifyFeature.Fields.Field[i].Name;
                            ListViewItem lsvItem = new ListViewItem(new string[] { itemName, identifyFeature.get_Value(identifyFeature.Fields.FindField(identifyFeature.Fields.Field[i].Name)).ToString() });
                            this.lsvQueryResult.Items.Add(lsvItem);
                        }
                        this.dockPnlQueryForm.Visibility = DevExpress.XtraBars.Docking.DockVisibility.Visible;
                        m_queryFeatureLayer = selectedFeatureLayer;
                        m_queryFeature = identifyFeature;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                COM.LIB.LOG.LogOperator.WriteLog(ex.Message);
            }

        }

        /// <summary>按基准地价测算选中要素的宗地地价
        /// </summary>
        /// <param name="selectedFeatureLayer"></param>
        /// <param name="calContentName"></param>
        private void calSelectedFeatureByJZ(IFeatureLayer selectedFeatureLayer, string calContentName)//
        {
            try
            {
                if (selectedFeatureLayer == null) return;
                IGeometry identityPoint = m_identityPoint;//identify点（缓冲1）
                #region identify点缓冲
                ITopologicalOperator topoOp = m_identityPoint as ITopologicalOperator;
                identityPoint = topoOp.Buffer(1);
                #endregion

                #region identity
                IIdentify2 identify2 = selectedFeatureLayer as IIdentify2;
                IArray identifyResultObjs = identify2.Identify(identityPoint, null);
                if (identifyResultObjs != null || identifyResultObjs.Count > 0)//循环该图层identify的每一个结果
                {
                    IFeatureIdentifyObj IdentifyObj = identifyResultObjs.get_Element(0) as IFeatureIdentifyObj;
                    IRowIdentifyObject rowIdentifyObj = IdentifyObj as IRowIdentifyObject;
                    IFeature identifyFeature = rowIdentifyObj.Row as IFeature;
                    if (identifyFeature != null)
                    {
                        SelectOnMouseDown(selectedFeatureLayer, identifyFeature);
                        string jzdj = identifyFeature.get_Value(identifyFeature.Fields.FindField("基准地价")).ToString();
                        string jzjb = identifyFeature.get_Value(identifyFeature.Fields.FindField("级别")).ToString();
                        //根据选择的图层数据，确定指标体系的修正内容表名称
                        string calContent = "";
                        switch (calContentName)
                        {
                            case "市区商业宗地价格测算":
                                calContent = "市区商业基准地价";
                                break;
                            case "市区住宅宗地价格测算":
                                calContent = "市区住宅基准地价";
                                break;
                            case "市区工业宗地价格测算":
                                calContent = "市区工业基准地价";
                                break;
                        }
                        FormStyle.OpenForm(this.ParentForm, new DJCalForm(selectedFeatureLayer, identifyFeature, calContent, jzdj, jzjb), true);
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                COM.LIB.LOG.LogOperator.WriteLog(ex.Message);
            }

        }

        /// <summary>出让价格测算
        /// </summary>
        /// <param name="selectedFeatureLayer"></param>
        /// <param name="targetLayerName"></param>
        private void calSellPriceOfSelectedFeature(IFeatureLayer selectedFeatureLayer,string targetLayerName)
        {
            try
            {
                if (selectedFeatureLayer == null) return;
                IGeometry identityPoint = m_identityPoint;//identify点（缓冲1）
                #region identify点缓冲
                ITopologicalOperator topoOp = m_identityPoint as ITopologicalOperator;
                identityPoint = topoOp.Buffer(1);
                #endregion
                #region identity
                IIdentify2 identify2 = selectedFeatureLayer as IIdentify2;
                IArray identifyResultObjs = identify2.Identify(identityPoint, null);
                if (identifyResultObjs != null && identifyResultObjs.Count > 0)//循环该图层identify的每一个结果
                {
                    IFeatureIdentifyObj IdentifyObj = identifyResultObjs.get_Element(0) as IFeatureIdentifyObj;
                    IRowIdentifyObject rowIdentifyObj = IdentifyObj as IRowIdentifyObject;
                    IFeature identifyFeature = rowIdentifyObj.Row as IFeature;
                    if (identifyFeature != null)
                    {
                        this.lsvQueryResult.Items.Clear();
                        SelectOnMouseDown(selectedFeatureLayer, identifyFeature);
                        m_queryFeatureLayer = selectedFeatureLayer;
                        m_queryFeature = identifyFeature;
                        //获取当前选中要素的宗地价格（按标定地价计算而来（ZDJG2）
                        if (identifyFeature.Fields.FindField("ZDJG2") == -1 || identifyFeature.Fields.FindField("CRJG") == -1)
                        {
                            MessageBox.Show("请在“数据”菜单中对数据进行处理。")
; return;
                        }
                        string zdjg2str = identifyFeature.get_Value(identifyFeature.Fields.FindField("ZDJG2")).ToString();
                        string crjg = identifyFeature.get_Value(identifyFeature.Fields.FindField("CRJG")).ToString();
                        string zdbh = identifyFeature.OID.ToString();
                        string zdlx = targetLayerName;
                        if(zdjg2str==""){
                            MessageBox.Show("您还未计算该宗地的价格。（注：按标定地价进行计算）");
                            return ;
                        }
                        int zdjg2= -1;

                        FormStyle.OpenForm(this.ParentForm,new SellPriceForm(selectedFeatureLayer, identifyFeature,(int.TryParse(zdjg2str, out zdjg2)) ? zdjg2 : -1, zdbh, zdlx, crjg),true );
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                COM.LIB.LOG.LogOperator.WriteLog(ex.Message);
            }
        }

        #region 过时
        /*
        /// <summary>
        /// 关于按标定地价的部分，还存在些问题，暂时缺省
        /// 1、按标定地价测算公式为确定
        /// 2、测试修正因子（开发程度等基于基准地价的指标没有）
        /// </summary>
        /// <param name="selectedFeatureLayer"></param>
        /// <param name="targetFeatureLayer"></param>
        private void calSelectedFeatureByBD(IFeatureLayer selectedFeatureLayer, IFeatureLayer targetFeatureLayer)//按标定地价测算选中要素的宗地地价
        {
            if (selectedFeatureLayer == null) return;
            IGeometry identityPoint = m_identityPoint;//identify点（缓冲1）
            #region identify点缓冲
            ITopologicalOperator topoOp = m_identityPoint as ITopologicalOperator;
            identityPoint = topoOp.Buffer(1);
            #endregion

            #region identity
            IIdentify2 identify2 = selectedFeatureLayer as IIdentify2;
            IArray identifyResultObjs = identify2.Identify(identityPoint, null);
            if (identifyResultObjs != null || identifyResultObjs.Count > 0)//循环该图层identify的每一个结果
            {
                IFeatureIdentifyObj IdentifyObj = identifyResultObjs.get_Element(0) as IFeatureIdentifyObj;
                IRowIdentifyObject rowIdentifyObj = IdentifyObj as IRowIdentifyObject;
                //确定测算宗地对象
                IFeature identifyFeature = rowIdentifyObj.Row as IFeature;
                if (identifyFeature != null)
                {
                    //搜寻附近3-5个标定样点
                    ISpatialFilter pSpatialFilter = new SpatialFilterClass();
                    double searchLength = 500;
                    int featureCount = 0;
                    while (featureCount < 3)
                    {
                        searchLength += 500;
                        pSpatialFilter.Geometry = GetBuffer(identifyFeature.Shape, searchLength);
                        pSpatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;//包含
                        featureCount = targetFeatureLayer.FeatureClass.FeatureCount(pSpatialFilter);
                    }

                    IFeatureCursor pFeatureCursor = targetFeatureLayer.FeatureClass.Update(pSpatialFilter, false);
                    IFeature pFeature = pFeatureCursor.NextFeature();
                    List<IFeature> featureList = new List<IFeature>();
                    while (pFeature != null && featureList.Count <= 3)
                    {
                        featureList.Add(pFeature);
                        pFeature = pFeatureCursor.NextFeature();
                    }
                    double[] weightArry = new double[3];
                    double[] priceArray = new double[3];
                    //计算权重：
                    for (int i = 0; i < weightArry.Length; i++)
                    {
                        if (double.TryParse(identifyFeature.get_Value(identifyFeature.Fields.FindField("标定地价")).ToString(), out priceArray[i]))
                        {
                            weightArry[i] = GetTwoGeometryDistance(identifyFeature.Shape, featureList[0].Shape);
                        }
                    }
                    //获取标定地价
                    double bdprice = (priceArray[0] * (weightArry[0] / (weightArry[0] + weightArry[1] + weightArry[2]))) + (priceArray[1] * (weightArry[1] / (weightArry[0] + weightArry[1] + weightArry[2]))) + (priceArray[2] * (weightArry[2] / (weightArry[0] + weightArry[1] + weightArry[2])));

                    //string jzdj = identifyFeature.get_Value(identifyFeature.Fields.FindField("基准地价")).ToString();
                    string jzjb = identifyFeature.get_Value(identifyFeature.Fields.FindField("级别")).ToString();
                    //根据选择的图层数据，确定指标体系的修正内容表名称
                    string calContentName = "市区商业宗地价格测算--按标定";//动态
                    string calContent = "";
                    switch (calContentName)
                    {
                        case "市区商业宗地价格测算":
                            calContent = "市区商业基准地价";
                            break;
                    }
                    DJCalForm djCalForm = new DJCalForm(selectedFeatureLayer, identifyFeature, calContent, bdprice.ToString(), jzjb);
                    djCalForm.Show();
                }
            }
            #endregion
        }
         */
        #endregion

        /// <summary> 高亮显示选中要素
        /// </summary>
        /// <param name="selectedFeaturelayer"></param>
        /// <param name="selectFeature"></param>
        public void SelectOnMouseDown(IFeatureLayer selectedFeaturelayer, IFeature selectFeature)
        {
            try
            {
                if (selectedFeaturelayer == null || selectFeature == null) return;
                axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, selectedFeaturelayer, null);
                this.axMapControlMainMap.Map.ClearSelection();
                axMapControlMainMap.Map.SelectFeature(selectedFeaturelayer, selectFeature);
                axMapControlMainMap.ActiveView.PartialRefresh(esriViewDrawPhase.esriViewGeoSelection, selectedFeaturelayer, null);
            }
            catch
            { return; }
        }

        //公共方法
        /// <summary>获取缓冲区
        /// </summary>
        /// <param name="oShape"></param>
        /// <param name="dbTolerance"></param>
        /// <returns></returns>
        public IGeometry GetBuffer(IGeometry oShape, double dbTolerance)
        {
            IGeometry oBuffer = null;
            if (oShape == null)
                return oBuffer;
            ITopologicalOperator pTopo = oShape as ITopologicalOperator;
            if (!pTopo.IsSimple)
            {//若是不是简单图形，进行简化处理惩罚
                pTopo.Simplify();
            }

            esriGeometryType iType = oShape.GeometryType;

            //参数不正确
            if (dbTolerance < 0 && iType != esriGeometryType.esriGeometryPolygon)
                return oBuffer;
            int iTry = 0;//测验测验10次
            while (oBuffer == null && iTry <= 10)
            {
                try
                {
                    //若是调用不成功，将缓冲间隔加0.01倍再试（若是第10次成功，则缓冲间隔比本来大了0.09倍）
                    //若是对缓冲间隔请求更严格，可以削减增量的倍数
                    //按照测试经验，一般最多测验测验三次就可以成功
                    oBuffer = pTopo.Buffer(dbTolerance * (1.0 + 0.01 * iTry));
                }
                catch
                {
                    oBuffer = null;
                    iTry = iTry + 1;
                }
            }
            return oBuffer;
        }

        /// <summary>获取两个几何图形的距离
        /// </summary>
        /// <param name="pGeometryA">几何图形A</param>
        /// <param name="pGeometryB">几何图形B</param>
        /// <returns>两个几何图形的距离</returns>
        private double GetTwoGeometryDistance(IGeometry pGeometryA, IGeometry pGeometryB)
        {
            IProximityOperator pProOperator = pGeometryA as IProximityOperator;
            if (pGeometryA != null || pGeometryB != null)
            {
                double distance = pProOperator.ReturnDistance(pGeometryB);
                return distance;
            }
            else
            {
                return 0;
            }
        }

        private void sBtnCal_Click(object sender, EventArgs e)//测算当前地价
        {
            if (m_queryFeatureLayer == null || m_queryFeature == null)
            {
                MessageBox.Show("请选择要测算的宗地要素！");
                return;
            }
            string jzdj = m_queryFeature.get_Value(m_queryFeature.Fields.FindField("基准地价")).ToString();
            string jzjb = m_queryFeature.get_Value(m_queryFeature.Fields.FindField("级别")).ToString();
            //根据选择的图层数据，确定指标体系的修正内容表名称
            string calContentName = "市区商业宗地价格测算";//动态
            string calContent = "";
            switch (calContentName)
            {
                case "市区商业宗地价格测算":
                    calContent = "市区商业基准地价";
                    break;
            }
            DJCalForm djCalForm = new DJCalForm(m_queryFeatureLayer, m_queryFeature, calContent, jzdj, jzjb);
            djCalForm.Show();
        }
    }
    #region 自定义类
    public class IdentifyLayerResultClass //一个图层identify的结果Class
    {
        public string layername { get; set; }
        //public IFeatureLayer featureLayer { get; set; }
        public List<IFeatureIdentifyObj> featureIdentifyObjList { get; set; }
    }
    #endregion
}
